package com.lmb.controller;

import com.lmb.bean.Lands;
import com.lmb.mapper.LandsDao;
import com.lmb.service.LandsService;
import com.lmb.util.Page;
import com.lmb.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin //允许跨域访问
@RequestMapping("/lands")
public class LandsController {
    @Autowired
    LandsDao landsDao;
    @Autowired
    LandsService landsService;
    @PostMapping
    public Result add(@RequestBody Lands lands)
    {
        Object obj=landsService.add(lands);
        return Result.success(obj);
    }
    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj=landsService.del(id);
        return Result.success(obj);
    }
    @PutMapping
    public Result edit(@RequestBody Lands lands){
        Object obj=landsService.edit(lands);
        return Result.success(obj);
    }
    @GetMapping("all")
    public Result all( Lands lands){
        Object obj=landsService.all(lands);
        return Result.success(obj);
    }
    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=landsService.one(id);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, Lands lands){
        landsService.page(page,lands);
        return Result.success(page);
    }
}
